package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-12-19
 * Time: 18:13
 */
public class Test {
   import java.util.ArrayList;
    public class Solution {
        public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
            ArrayList<Integer> arraylist=new ArrayList<>();
            ListNode cur=listNode;
            while(cur!=null){
                arraylist.add(0,cur.val);
                cur=cur.next;
            }


            return  arraylist;//运用数组的头插法

        }
    }

}
